/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cinemasystem.app.modules.movieservice_nomaphelo.Impl;

import com.cinemasystem.app.modules.movieservice_nomaphelo.MovieGenreService;
import com.cinemasystem.model.MovieGenre;
import com.cinemasystem.services.crud.MovieGenreCrudService;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author given
 */
public class MovieGenreServiceImpl implements MovieGenreService{
    private MovieGenreCrudService movieGenreCrudService;
    private ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:com/cinemasystem/app/conf/applicationContext-*.xml");

    @Override
    public MovieGenre getGenre(String genre) {
        movieGenreCrudService = (MovieGenreCrudService) ctx.getBean("movieGenreCrudService");
        List<MovieGenre> movieGenre = movieGenreCrudService.findAll();
        for(MovieGenre mg: movieGenre){
            if(genre.equalsIgnoreCase(mg.getGenre())){
                return mg;
            }
        }
        return null;
    }
    
}
